You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Harden the admin image upload endpoint by restoring nonce protection and validating uploaded files from their actual file type instead of trusting the request MIME header.
Why
The wpf_upload_image route is currently exempt from wpf_admin_nonce verification, which leaves the admin upload action open to CSRF. It also trusts $_FILES['file']['type'], which is client-controlled and should not be the only file-type check.
Fix
Require the existing admin nonce for all global settings routes, including image upload
Append the nonce to the localized admin upload URL
Reject missing uploads early
Validate uploads with wp_check_filetype_and_ext() and allow only jpg/jpeg/png files
Confidence
High. The route already has an admin nonce in localized data, the change is localized, and both modified files pass php -l.
includes/Classes/Menu.php - Nonce properly added to URL
Security Analysis
The changes properly address the reported vulnerabilities:
CSRF Fix (GlobalSettingsHandler.php:24): Removed the conditional that exempted wpf_upload_image from nonce validation. Nonce is now validated for all routes.
File Type Validation (GlobalSettingsHandler.php:100-103): Replaced trusting client-provided MIME type ($_FILES['file']['type']) with wp_check_filetype_and_ext() which inspects actual file content. Uses strict comparison (in_array(..., true)) for added security.
Empty File Check (GlobalSettingsHandler.php:95-97): Added early validation to reject missing or invalid uploads.
Nonce in URL (Menu.php:160): The nonce is now included in the image_upload_url query string for the frontend to use.
All error responses now consistently use wp_send_json_error().
Reviewed by minimax-m2.5-20260211 · 155,862 tokens
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Harden the admin image upload endpoint by restoring nonce protection and validating uploaded files from their actual file type instead of trusting the request MIME header.
Why
The
wpf_upload_imageroute is currently exempt fromwpf_admin_nonceverification, which leaves the admin upload action open to CSRF. It also trusts$_FILES['file']['type'], which is client-controlled and should not be the only file-type check.Fix
wp_check_filetype_and_ext()and allow only jpg/jpeg/png filesConfidence
High. The route already has an admin nonce in localized data, the change is localized, and both modified files pass
php -l.